<?php
include_once ("databaseconnection.php");
$_SESSION['successfp']="";
$Log_Username=$_POST['Username'];
$NewPassword=$_POST['New_Password'];
$PasswordVar=$_POST['Veri_New_Password'];
 if($NewPassword!="")
	{
	if($PasswordVar=="")
 {
 $_SESSION['error']="Please Varify your new Password!";
 }
 if($PasswordVar!="")
 {
if($NewPassword!=$PasswordVar)
{
$_SESSION['error']="Your varification is failed please try again!";
}

if($NewPassword==$PasswordVar)
{
$md5npass=md5($NewPassword);
date_default_timezone_set("Europe/Paris");
    $t_d=date("Y/m/d");
$sql=mysql_query("UPDATE user SET Password='$md5npass',Last_Updated_Date='$t_d' WHERE Login_Username='$Log_Username'");
if($sql)
  {
  $_SESSION['username']=$Log_Username;
 $_SESSION['password']=$NewPassword;
  $_SESSION['successfp']="succ";
  $queryres=mysql_query("SELECT * FROM user WHERE Login_Username='$Log_Username' AND Password='$md5npass'");
if($queryres)
{
if($row=mysql_fetch_array($queryres))
  {
	$_SESSION['First_Name']=$row['First_Name'];
	$_SESSION['Last_Name']=$row['Last_Name'];
	$_SESSION['Access_Type']=$row['Access_Type'];
	$_SESSION['NIC_Number']=$row['NIC_Number'];
	$_SESSION['Mail_Id']=$row['E_Mail'];
}
}
}
if(!$sql)
  {
   $_SESSION['success']="No";
$_SESSION['error']="Sorry unable to change your password please try again!";
}
 }
  }
	}
	 if($NewPassword=="")
	{
	$_SESSION['error']="Please fill all!";
    }
?>